package com.servicecloud.service;

import java.util.List;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.servicecloud.config.FeignClientConfig;
import com.servicecloud.entities.Dept;

/**
 * 面向接口服务
 * 
 * @Description：<br>
 * FeignClientConfig:安全认证配置类
 * 一个实现了FallbackFactory接口的类DeptClientServiceFallbackFactory，作用就是进行Hystrix的服务降级处理(服务降级是在客服端处理，注意区分)
 * 服务熔断：如果该服务调用出现错误，那么可以返回固定的信息（在服务端处理）
 * 服务降级：如果服务不能提供服务，客服端还是会获得固定的提示信息（需要在客服端处理）<br>
 * （实际开发中把该service独立成为一个模块作为服务提供的接口）
 */
//@FeignClient(value = "MICROSERVICECLOUD", configuration = FeignClientConfig.class)
//@FeignClient(value = "MICROSERVICECLOUD", configuration = FeignClientConfig.class, fallbackFactory = DeptClientServiceFallbackFactory.class)
//改为zuul的服务代理方式
//MICROSERVICECLOUD-ZUUL-GATEWAY:路由zuul网关的注册再eureka中的名字
@FeignClient(value = "MICROSERVICECLOUD-ZUUL-GATEWAY", configuration = FeignClientConfig.class, fallbackFactory = DeptClientServiceFallbackFactory.class)
public interface DeptClientService {
	/*
	 * 通过服务
	 */
	
//	@RequestMapping(value = "/dept/get/{id}", method = RequestMethod.GET)
//	public Dept get(@PathVariable("id") long id);
//
//	@RequestMapping(value = "/dept/list", method = RequestMethod.GET)
//	public List<Dept> list();
//
//	@RequestMapping(value = "/dept/add", method = RequestMethod.POST)
//	public boolean add(Dept dept);
	
	/*
	 * 通过路由代理方式
	 */
	@RequestMapping(value = "/Gavin/mydept/dept/get/{id}", method = RequestMethod.GET)
	public Dept get(@PathVariable("id") long id);

	@RequestMapping(value = "/Gavin/mydept/dept/list", method = RequestMethod.GET)
	public List<Dept> list();

	@RequestMapping(value = "/Gavin/mydept/dept/add", method = RequestMethod.POST)
	public boolean add(Dept dept);
}
